<extend name="Public/base"/>

<block name="body">
    <!-- 标题栏 -->
    <div class="main-title">
        <h2>相册</h2>
    </div>
	<div class="cf">
		<div class="fl">
		<empty name="model.extend">
			<div class="tools">
			</div>
		</empty>
		</div>
		<!-- 高级搜索 -->
		<div class="search-form fr cf">
			<div class="sleft">

			</div>

		</div>
	</div>

    <h3>点击图片删除</h3>
    <!-- 数据列表 -->
    <div class="data-table">
        <div class="data-table table-striped">
        <volist name='res' id='vol'>
            <p>上传时间：{$vol.create_time|date="Y-m-d H:i:s",###}</p>
            <input type="hidden" name="id" value="{$vol.uid}">
            <input type="hidden" name="imgid" value="{$vol.id}">
            <volist name='vol.img' id='v'>
                <img class="img-class-this" width="150" height="150" src="__ROOT__{$v|getimg=###}" />
                <input type="button" class="btn img-class" value="删除">
                <input type="hidden" name="img" value="{$v}">
            </volist>
        </volist>
        </div>
    </div>
    <div class="page">
        {$_page|default=''}
    </div>
</block>

<block name="script">
<script type="text/javascript">
$(function(){
        $('.img-class').on('click',function(){
            // var src = $('input:hidden');
            var msg = confirm('你确定要删除吗？ ');
            if(msg){
                var src = $(this).next('input:hidden').val();
                var id  = $(this).prevAll('input[name=imgid]').val();
                $.ajax({
                    url: "{:U('ajaxDel')}",
                    type: 'POST',
                    dataType: 'json',
                    data: {img: src,id:id},
                    success:function($data){
                        window.location.reload();
                    }
                })
            }
        });
        $('.img-class-this').on('click',function(){
           var src = $(this).attr("src");
              layer.open({
                  type: 1,
                  area: ['500px', '548px'],
                  shadeClose: true, //点击遮罩关闭
                  content: "<img class='class-img' src='"+src+"'>"
                  });
        });







    });

$(function(){
	//搜索功能
	$("#search").click(function(){
		var url = $(this).attr('url');
        var query  = $('.search-form').find('input').serialize();
        query = query.replace(/(&|^)(\w*?\d*?\-*?_*?)*?=?((?=&)|(?=$))/g,'');
        query = query.replace(/^&/g,'');
        if( url.indexOf('?')>0 ){
            url += '&' + query;
        }else{
            url += '?' + query;
        }
		window.location.href = url;
	});

    //回车自动提交
    $('.search-form').find('input').keyup(function(event){
        if(event.keyCode===13){
            $("#search").click();
        }
    });

})
</script>
</block>
